﻿(function () {


  var instances = {};

  puxu.Editor = function (options) {
    var editor = new puxu.EdPuXu(options);
    editor.options.editor = editor;
    utils.loadFile(document, {
      href: editor.options.themePath + editor.options.theme + "/css/puxuditor.css",
      tag: "link",
      type: "text/css",
      rel: "stylesheet"
    });

    var oldRender = editor.render;

    editor.render = function (holder) {
      if (holder.constructor === String) {
        editor.key = holder;
        instances[holder] = editor;
      }

    }

    return editor;
  }

  /**
  * 以给定的参数集合创建一个编辑器实例，对于未指定的参数，将应用默认参数。
  * @constructor
  * @ID 编辑器绑定div ID
  * @LeftID 左边编辑区
  * @RightID 右边编辑区
  * @example
  */
  puxu.PuXu = function (options) {
    var editor = instances[options.ID];
    if (!editor) {
      editor = instances[options.ID] = new puxu.Editor(options);
      editor.render(options.ID);
    }
    return editor;
  }
  //判断参数对象是否存在
  //if (puxuBox && puxuBox.ID) {
  //  var pxBox = puxu.PuXu(puxuBox);
  //  console.log(pxBox)
  //}
})();